package com.sky.controller.user;

import com.sky.constant.RedisKeyConstant;
import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wjh
 * @create 2023-07-08
 */
@RestController("userShopController")
@RequestMapping("/user/shop")
@Slf4j
public class ShopController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("/status")
    public Result<Integer> getStatus() {
        String shop_status = stringRedisTemplate.opsForValue().get(RedisKeyConstant.SHOP_STATUS);
        if (shop_status != null) {
            return Result.success(Integer.valueOf(shop_status));
        }
        return Result.error("获取店铺营业状态失败");
    }
}
